home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 52
/
Volume 52 - JOGO DISK .iso
/
Games
/
skipandgouls.swf
/
scripts
/
__Packages
/
characters
/
DutchManManager.as
< prev
next >
Wrap
Text File
|
2007-10-01
|
2KB
|
70 lines
class characters.DutchManManager extends sarbakan.visual.element.DynamicElement
{
static var PICK_DELAY = 50;
function DutchManManager()
{
super();
this.bAlwaysActive = true;
this.aDutchMan = [];
this.enable();
this.nPickDelayCount = 0;
}
function add(l_oDutchMan, l_nX, l_nY)
{
this.aDutchMan.push({dutchman:l_oDutchMan,x:l_nX,y:l_nY});
}
function remove(l_oDutchMan)
{
for(var _loc3_ in this.aDutchMan)
{
if(this.aDutchMan[_loc3_].dutchman == l_oDutchMan)
{
this.aDutchMan.splice(_loc3_,1);
break;
}
}
if(l_oDutchMan == this.oCurrentDutchman)
{
this.onDutchManOut();
}
}
function onDutchManOut()
{
this.oCurrentDutchman.setState("idle");
this.setState("idle");
}
function idle()
{
if(++this.nPickDelayCount == characters.DutchManManager.PICK_DELAY)
{
this.nPickDelayCount = 0;
this.setState("pick");
}
}
function pick()
{
var _loc4_ = undefined;
var _loc3_ = 100000;
var _loc2_ = undefined;
for(var _loc5_ in this.aDutchMan)
{
_loc2_ = sarbakan.utils.MoreMath.getDistance(this.aDutchMan[_loc5_].dutchman.mc._x,this.aDutchMan[_loc5_].dutchman.mc._y,this.oOwner.oDynamicElements.spongebob.mc._x,this.oOwner.oDynamicElements.spongebob.mc._y);
if(_loc2_ < _loc3_)
{
_loc4_ = _loc5_;
_loc3_ = _loc2_;
}
}
this.oCurrentDutchman = this.aDutchMan[_loc4_].dutchman;
if(this.oCurrentDutchman)
{
this.aDutchMan[_loc4_].dutchman.setState("idleIn");
this.setState("wait");
}
else
{
this.setState("idle");
}
}
}